]> dgit.raspbian.org Git - ostree.git/commit
state-overlay: Fix ENODATA handling for GLib < 2.74
authorJoseph Marrero Corchado <jmarrero@redhat.com>
Tue, 16 Dec 2025 19:30:47 +0000 (14:30 -0500)
committerJoseph Marrero Corchado <jmarrero@redhat.com>
Tue, 16 Dec 2025 20:54:56 +0000 (15:54 -0500)
commit87203ffeb637d0e01df3e156f5946422ff72e83a
treeff4d1e0b43765a7f84e7a5484bb64c3f4fdb9ca9
parentc6f0b5b2bc26b22fbceee0dc28a0f31349c28d41
state-overlay: Fix ENODATA handling for GLib < 2.74

The state overlay feature fails on first boot with:

  error: lgetxattr(user.ostree.deploymentcsum): No data available

This happens because `lgetxattrat_allow_noent()` checks for
`G_IO_ERROR_INVALID_DATA` to detect when an xattr doesn't exist.
However, GLib's `g_io_error_from_errno()` only maps `ENODATA` to
`G_IO_ERROR_INVALID_DATA` since GLib 2.74. Older versions (such as
GLib 2.68 shipped in CentOS Stream 9) return `G_IO_ERROR_FAILED`
instead, causing the check to fail and the error to propagate.

This creates a chicken-and-egg problem: the code tries to read the
`user.ostree.deploymentcsum` xattr before it can set it, but the read
fails on fresh overlay directories where the xattr hasn't been set yet.

Fix this by checking `errno == ENODATA` directly after the failed call,
which is portable across all GLib versions. Also rename the function
from `lgetxattrat_allow_noent` to `lgetxattrat_allow_nodata` to more
accurately reflect its purpose (ENODATA vs ENOENT).

This bug has existed since the state overlay feature was introduced in
v2024.1 but was masked on systems with GLib >= 2.74 (e.g., Fedora,
CentOS Stream 10) where the mapping happens to exist.

Assisted-by: Claude Code (Opus 4.5)
Signed-off-by: Joseph Marrero Corchado <jmarrero@redhat.com>
src/ostree/ot-admin-builtin-state-overlay.c